import { getRandomDateTime, getNowDate, getFeatureDate } from '../../../../utils'
import Mock from 'mockjs'
export const smsTemplateMock = pageSize => {
  const result: any[] = []
  const codeList = ['TENCENT', 'HUAWEI', 'QINIU', 'ALIYUN', 'DEBUG_DING_TALK']
  for (let i = 0; i < pageSize; i++) {
    const res = getTemplateContentAndParams()
    result.push({
      id: i + 1,
      type: Mock.mock('@integer(1, 3)'),
      apiTemplateId: Mock.mock('@id'),
      channelId: Mock.mock('@integer(1, 100)'),
      channelCode: codeList[Mock.mock('@integer(0, 4)')],
      name: Mock.mock('@ctitle'),
      code: Mock.mock('@word'),
      content: res.content,
      params: res.params,
      status: Mock.mock('@integer(0, 1)'),
      remark: Mock.mock('@csentence()'),
      creator: '1',
      create_time: getRandomDateTime(getFeatureDate(-10), getNowDate()),
      updater: '',
      update_time: '',
      deleted: false,
      deleted_time: ''
    })
  }
  return result
}

const getTemplateContentAndParams = () => {
  const len = Mock.mock('@integer(1, 4)')
  const res: any = {
    content: '',
    params: []
  }
  for (var i = 0; i < len; i++) {
    const param = Mock.mock('@word')
    const text = Mock.mock('@ctitle')
    res.params.push(param)
    if (i % 2 === 0) {
      res.content += '{' + param + '}，' + text + '，'
    } else {
      res.content += text + '{' + param + '}。'
    }
  }
  return res
}
